package com.cc.service.impl;

import com.cc.dao.UserDao;
import com.cc.dao.impl.UserDaoImpl;
import com.cc.entity.EmployeeProfiles;
import com.cc.entity.LeaveApplication;
import com.cc.entity.Page;
import com.cc.entity.User;
import com.cc.service.UserService;

public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();
    /**
     * 登录
     * @param username
     * @param password
     * @return
     */
    @Override
    public User login(String username, String password) {
        return userDao.login(username, password);
    }

    @Override
    public EmployeeProfiles getEmployeeById(Integer userId) {
        return userDao.getEmployeeById(userId);
    }

    @Override
    public Boolean addEmployee(EmployeeProfiles employeeProfiles) {
        return userDao.addEmployee(employeeProfiles)>0?true:false;
    }

    /**
     * 更新员工档案
     * @param employeeProfiles
     * @return
     */
    @Override
    public Boolean updateEmployeeProfiles(EmployeeProfiles employeeProfiles) {
        return userDao.updateEmployeeProfiles(employeeProfiles)>0?true:false;
    }
    /**
     * 获取请假申请
     * @param employeeId
     * @return
     */
    @Override
    public LeaveApplication getLeaveApplicationById(Integer employeeId) {
        return userDao.getLeaveApplicationById(employeeId);
    }

    @Override
    public Page<EmployeeProfiles> findEmployeeByPage(String name, Page page) {
        return userDao.findByPage(name, page);
    }

    @Override
    public int getEmployeeList(String name) {
        return userDao.getTotal(name);
    }

    @Override
    public boolean deleteEmployee(int id) {
        return userDao.deleteEmployee(id)>0?true:false;
    }
}
